<%= turbo_frame_tag :drawer do %>
  <%= drawer_header(Spree.t(:translations)) %>
  <% if @locales.any? %>
    <%= form_for @object, url: spree.admin_translation_path(@object.id, resource_type: model_class.to_s), method: :put do |f| %>
      <div class="drawer-body">
        <ul class="nav nav-pills mb-3">
          <% @locales.each do |locale| %>
            <% normalized = normalized_locale(locale) %>
            <%= nav_item(
                 Spree.t('i18n.this_file_language', locale: locale),
                 spree.edit_admin_translation_path(@object, resource_type: model_class.to_s, translation_locale: locale),
                 active: (normalized == @selected_translation_locale)
      
                ) %>
          <% end %>
        </ul>

        <%= hidden_field_tag :translation_locale, @selected_translation_locale %>
        <% options = { f: f, resource: @object, locale: @selected_translation_locale } %>

        <%= render "spree/admin/translations/#{model_class.name.demodulize.underscore.pluralize}/form", options %>
      </div>
      <div class="drawer-footer">
        <%= turbo_save_button_tag %>
        <%= drawer_discard_button %>
      </div>
    <% end %>
  <% else %>
    <div class="drawer-body">
      <div class="text-muted p-5 d-flex align-items-center w-100 justify-content-center flex-column">
        <%= icon 'language', class: 'mb-3 opacity-50', style: 'font-size: 2rem;' %>
        <p class="text-center"><%= Spree.t('admin.translations.no_translations_configured') %></p>

        <% if can?(:edit, current_store) %>
          <%= link_to_with_icon 'settings', Spree.t('admin.translations.configure_store'), spree.edit_admin_store_path(section: 'general-settings'), class: 'btn btn-primary', data: { 'turbo-frame': '_top' } %>
        <% end %>
      </div>
    </div>
  <% end %>
<% end %>